package bjut.zrpc.core.optimization.constant;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @Author: zhuzhiming
 * @Date: 2022/6/23 21:27
 */
public final class ZRpcConstant {

    public static String SERVICE_HOST;

    static {
        try {
            SERVICE_HOST = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

    public static final int NETTY_SERVER_PORT = 2829;

    public static final String ZRPC_ROOT_PATH = "/zRpc/";

    public static final byte[] MAGIC_NUMBER = {(byte) 'z', (byte) 'r', (byte) 'p', (byte) 'c'};
    public static final byte VERSION = 1;
    public static final int HEAD_LENGTH = 16;

    public static final byte REQUEST_TYPE = 0;
    public static final byte RESPONSE_TYPE = 1;
    public static final byte HEART_REQUEST_TYPE = 2;
    public static final byte HEART_RESPONSE_TYPE = 3;

    public static final String HEART_REQUEST_DATA = "PING";
    public static final String HEART_RESPONSE_DATA = "PONG";

    public static final int MAX_LENGTH = 20 * 1024 * 1024;


    public static final int SUCCESS_CODE = 200;
    public static final String SUCCESS_MESSAGE = "SUCCESS";
    public static final int FAIL_CODE = 500;
    public static final String FAIL_MESSAGE = "FAIL";

}
